<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="首跟时间">
              <j-date placeholder="请选择首跟时间" v-model="queryParam.followTime"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="项目名称">
              <a-input placeholder="请输入项目名称" v-model="queryParam.projectName"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="项目阶段">
              <j-dict-select-tag type="list" v-model="queryParam.projectStatus" dictCode="project_status" placeholder="请输入项目阶段" />
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="拟落落地区域">
                <a-input placeholder="请输入拟落落地区域" v-model="queryParam.place"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="企业属性">
                <a-input placeholder="请输入企业属性" v-model="queryParam.enterpriseProperties"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="产业分类">
                <a-input placeholder="请输入产业分类" v-model="queryParam.ndustrialClassification"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="具体分类">
                <j-dict-select-tag type="list" v-model="queryParam.classificationDetail" dictCode="classification_detail" placeholder="请输入具体分类" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="线索提供人">
                <a-input placeholder="请输入线索提供人" v-model="queryParam.provider"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="具体对接人">
                <a-input placeholder="请输入具体对接人" v-model="queryParam.contractPerson"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="责任部门">
                <a-input placeholder="请输入责任部门" v-model="queryParam.department"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="分管领导">
                <a-input placeholder="请输入分管领导" v-model="queryParam.leader"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="总投资金额">
                <a-input placeholder="请输入总投资金额" v-model="queryParam.totalMouney" defaultValue="0"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('招商线索表')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <investment-promotion-clue-modal ref="modalForm" @ok="modalFormOk"></investment-promotion-clue-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import InvestmentPromotionClueModal from './modules/InvestmentPromotionClueModal'

  export default {
    name: 'InvestmentPromotionClueList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      InvestmentPromotionClueModal
    },
    data () {
      return {
        description: '招商线索表管理页面',
        // 表头
        columns: [
          {
            title:'首跟时间',
            align:"center",
            dataIndex: 'followTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'项目阶段',
            align:"center",
            dataIndex: 'projectStatus',
            customRender:function (projectStatusData){
              if(projectStatusData=='1'){
                return "线索";
              }else if(projectStatusData=='2'){
                return "已签约";
              }else if(projectStatusData=='3'){
                return "已注册";
              }else if(projectStatusData=='4'){
                return "已增资";
              }else if(projectStatusData=='5'){
                return "已备案";
              }else if(projectStatusData=='6'){
                return "已外资备案";
              }else{
                return "无";
              }
            }
          },
          {
            title:'项目名称',
            align:"center",
            dataIndex: 'projectName'
          },
          {
            title:'拟落落地区域',
            align:"center",
            dataIndex: 'place'
          },
          {
            title:'企业属性',
            align:"center",
            dataIndex: 'enterpriseProperties'
          },
          {
            title:'产业分类',
            align:"center",
            dataIndex: 'ndustrialClassification'
          },
          {
            title:'具体分类',
            align:"center",
            dataIndex: 'classificationDetail',
            customRender:function (classificationDetailData){
              if(classificationDetailData=='1'){
                return "农林业";
              }else if(classificationDetailData=='2'){
                return "商贸";
              }else if(classificationDetailData=='3'){
                return "制造业";
              }else if(classificationDetailData=='4'){
                return "文旅";
              }else if(classificationDetailData=='5'){
                return "水";
              }else if(classificationDetailData=='6'){
                return "工业";
              }else if(classificationDetailData=='7'){
                return "能源";
              }else if(classificationDetailData=='8'){
                return "大数据物联网";
              }else if(classificationDetailData=='9'){
                return "交通";
              }else if(classificationDetailData=='10'){
                return "城市基础设施";
              }else if(classificationDetailData=='11'){
                return "金融业";
              }else if(classificationDetailData=='12'){
                return "社会公共事业";
              }else if(classificationDetailData=='13'){
                return "服务业";
              }else{
                return "无";
              }
            }
          },
          {
            title:'线索提供人',
            align:"center",
            dataIndex: 'provider'
          },
          {
            title:'具体对接人',
            align:"center",
            dataIndex: 'contractPerson'
          },
          {
            title:'责任部门',
            align:"center",
            dataIndex: 'department'
          },
          {
            title:'分管领导',
            align:"center",
            dataIndex: 'leader'
          },
          {
            title:'总投资金额',
            align:"center",
            dataIndex: 'totalMouney',
            customRender:function (totalMouneyData){
              return totalMouneyData + "亿元";
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/org.jeecg.modules.clue/investmentPromotionClue/list",
          delete: "/org.jeecg.modules.clue/investmentPromotionClue/delete",
          deleteBatch: "/org.jeecg.modules.clue/investmentPromotionClue/deleteBatch",
          exportXlsUrl: "/org.jeecg.modules.clue/investmentPromotionClue/exportXls",
          importExcelUrl: "org.jeecg.modules.clue/investmentPromotionClue/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'date',value:'followTime',text:'首跟时间'})
        fieldList.push({type:'string',value:'projectStatus',text:'项目阶段',dictCode:''})
        fieldList.push({type:'string',value:'projectName',text:'项目名称',dictCode:''})
        fieldList.push({type:'string',value:'projectProperties',text:'项目属性',dictCode:''})
        fieldList.push({type:'string',value:'investmentName',text:'投资主体名称',dictCode:''})
        fieldList.push({type:'string',value:'isKnown',text:'是否名企',dictCode:''})
        fieldList.push({type:'string',value:'knownType',text:'名企类型',dictCode:''})
        fieldList.push({type:'string',value:'place',text:'拟落落地区域',dictCode:''})
        fieldList.push({type:'string',value:'projectDetail',text:'项目内容和规模',dictCode:''})
        fieldList.push({type:'string',value:'progressProgress',text:'项目最新进展情况',dictCode:''})
        fieldList.push({type:'string',value:'enterpriseProperties',text:'企业属性',dictCode:''})
        fieldList.push({type:'string',value:'ndustrialClassification',text:'产业分类',dictCode:''})
        fieldList.push({type:'string',value:'classificationDetail',text:'具体分类',dictCode:''})
        fieldList.push({type:'string',value:'dockingPeople',text:'区县对接人及联系方式',dictCode:''})
        fieldList.push({type:'string',value:'enterprisePeople',text:'企业联系人及联系方式',dictCode:''})
        fieldList.push({type:'string',value:'provider',text:'线索提供人',dictCode:''})
        fieldList.push({type:'string',value:'contractPerson',text:'具体对接人',dictCode:''})
        fieldList.push({type:'string',value:'department',text:'责任部门',dictCode:''})
        fieldList.push({type:'string',value:'leader',text:'分管领导',dictCode:''})
        fieldList.push({type:'string',value:'isSubmit',text:'是否上报招商办',dictCode:''})
        fieldList.push({type:'date',value:'submitTime',text:'上报时间'})
        fieldList.push({type:'double',value:'totalMouney',text:'总投资金额',dictCode:''})
        fieldList.push({type:'double',value:'foreignMoney',text:'外资金额',dictCode:''})
        fieldList.push({type:'double',value:'domesticMoney',text:'内资金额',dictCode:''})
        fieldList.push({type:'date',value:'createTime',text:'创建时间'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>